package com.daylightrobbery.mapper;

import com.daylightrobbery.entity.Account;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;


@Mapper
public interface AccountMapper {

    @Insert("INSERT INTO accounts (account, password, ctime, phone) VALUES (#{account.account}, #{account.password}, #{account.ctime}, #{account.phone})")
    int insertAccount(@Param("account") Account account);

    @Select("SELECT * FROM accounts WHERE uid = #{uid}")
    Account findAccountById(@Param("uid") String uid);


    @Select("SELECT * FROM accounts WHERE account = #{account}")
    Account findAccountByAccount(@Param("account") String account);

    @Update("UPDATE accounts SET account = #{account.account}, password = #{account.password}, ctime = #{account.ctime}, phone = #{account.phone} WHERE uid = #{account.uid}")
    void updateAccount(@Param("account") Account account);

    @Delete("DELETE FROM accounts WHERE uid = #{uid}")
    void deleteAccount(@Param("uid") int uid);
}
